# Simulate League Standings

> `POST /api/esports/{league}/standings/simulate`: Esports endpoint of the Rone Arena API.

Re-rank a professional league's regular season after changing match results, to see what a different result would do to the table and the playoff line.

The schedule and real results are the league's live ones (see the schedule endpoints). Send `{"results": []}` to get the current table with statuses. **eliminated** is how many teams at the bottom miss the playoffs; it defaults to 3 for Indonesia (`id`) and 2 for the Philippines (`ph`).

Matches are first to 2 games, so a finished match is 2-0, 2-1, 1-2 or 0-2 (a 1-1 needs a deciding game). A team gets 1 match point per match won. Teams are ranked by match points, then net game wins (games won minus games lost), then head-to-head among the tied teams; a tie that survives all three is reported as `unresolved`. The same rules reproduce the official Indonesian and Philippine tables.

Each team also gets a **status** from what it can still reach: `clinched` (certain to be in the playoffs), `eliminated` (certain to miss them) or `alive`. The status is exact once the season is over and conservative before that, so a decided team can still read `alive`, never the other way round.

Each team also has **playoff_probability**, its chance in percent, with every decimal the simulation gives, of finishing in the playoff spots. It comes from simulating the matches still to play: with **model** `form` (default) a team's chance in a match follows its record so far, with `even` every match is a coin flip, and the winner takes the match 2-0 in 62% of cases (the real share). **simulations** sets how many seasons are simulated; omit it to let the server choose. Clinched teams read 100 and eliminated teams 0. The same request always returns the same numbers, and with the default sample they are accurate to about one percentage point.

To edit results, send them in **results** as `week`, `team1`, `team2`, `score1`, `score2`; either team order works, and leaving both scores out clears a match. Matches you do not mention keep their real result.

The real schedule is cached for 5 minutes.

## Request

`POST https://arena.rone.dev/api/esports/{league}/standings/simulate`

### Parameters

| Name | In | Type | Required | Default | Description |
| --- | --- | --- | --- | --- | --- |
| `league` | path | string | yes |  | `id` for Indonesia or `ph` for the Philippines. One of: `id`, `ph`. |

### Request body

`application/json`, required

```json
{
  "results": [
    {
      "week": 8,
      "team1": "NAVI",
      "team2": "TLID",
      "score1": 0,
      "score2": 2
    }
  ],
  "eliminated": 3
}
```

### Example

```bash
curl -X POST 'https://arena.rone.dev/api/esports/{league}/standings/simulate' \
  -H 'Content-Type: application/json' \
  -d '{"results": [{"week": 8, "team1": "NAVI", "team2": "TLID", "score1": 0, "score2": 2}], "eliminated": 3}'
```

## Example response

```json
{
  "teams": 9,
  "weeks_count": 9,
  "playoff_spots": 6,
  "eliminated": 3,
  "matches_played": 61,
  "matches_remaining": 11,
  "edited_matches": 1,
  "probability_model": "form",
  "probability_simulations": 10909,
  "weeks": [
    {
      "week": 8,
      "matches": [
        {
          "team1": {
            "name": "NAVI",
            "full_name": "NAVI",
            "logo": "https://wsrv.nl/?url=https%3A%2F%2Fexample.com%2Fteams%2Fevos.png"
          },
          "team2": {
            "name": "TLID",
            "full_name": "TLID",
            "logo": "https://wsrv.nl/?url=https%3A%2F%2Fexample.com%2Fteams%2Fevos.png"
          },
          "score1": 0,
          "score2": 2,
          "state": "edited"
        }
      ]
    }
  ],
  "standings": [
    {
      "rank": 1,
      "team": {
        "name": "NAVI",
        "full_name": "NAVI",
        "logo": "https://wsrv.nl/?url=https%3A%2F%2Fexample.com%2Fteams%2Fevos.png"
      },
      "match_point": 10,
      "match_wl": {
        "win": 10,
        "lose": 4
      },
      "net_game_win": 12,
      "game_wl": {
        "win": 21,
        "lose": 9
      },
      "played": 14,
      "remaining": 4,
      "max_match_point": 14,
      "tiebreak": "net_game_win",
      "status": "alive",
      "in_playoffs_zone": true,
      "playoff_probability": 97.33944954128441
    }
  ]
}
```

## Links

- Try it in the playground: https://arena.rone.dev/web/esports/{league}/standings/simulate
- Esports endpoints: https://arena.rone.dev/web/esports.md
- OpenAPI schema: https://arena.rone.dev/api/openapi.json
